﻿#region License
/* ---------------------------------------------------------------- *
 *
 * This file is part of the Xcoordination Application Space
 * ("XcoAppSpace") http://www.xcoordination.com
 *
 * Copyright (C) 2009 Xcoordination http://www.xcoordination.com
 *
 * XcoAppSpace is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General
 * Public License as published by the Free Software Foundation.
 *
 * XcoAppSpace is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 * or write to the Free Software Foundation, Inc., 51 Franklin
 * Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * ---------------------------------------------------------------- */
#endregion

using System;

namespace XcoAppSpaces.Core.Ports.Remoting
{
	/// <summary>
	/// Provides information about the currently processed message within a remote port receiver method.
	/// </summary>
	public class MessageContext
	{
		[ThreadStatic] private static MessageContext _current;

		/// <summary>
		/// If used while processing a message from a port or worker,
		/// returns the MessageContext for the given message.
		/// </summary>
		public static MessageContext Current
		{
			get { return _current; }
			internal set { _current = value; }
		}

		/// <summary>
		/// Returns true if the message was posted from a remote location, or false if it was posted locally.
		/// </summary>
		public bool IsRemoteMessage { get; set; }

		/// <summary>
		/// The address of the remote space, if the message was posted remotely.
		/// </summary>
		public string RemoteAddress { get; set; }

		/// <summary>
		/// The name of the transport service with which the message has been received, if it was posted remotely.
		/// </summary>
		public string TransportServiceName { get; set; }

		/// <summary>
		/// The id of the session, if the message was posted to a worker remotely. The SessionID is provided by
		/// the security service
		/// </summary>
		public Guid? SessionID { get; set; }

		/// <summary>
		/// The name of the user that posted the message, if it was posted to a worker remotely. The Username
		/// is provided by the security service.
		/// </summary>
		public string Username { get; set; }

	}
}
